﻿using BehaviorModel.Block;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace BehaviorModel.XmlSerializer
{
    /// <summary>
    /// Factory for creating XmlDeserialization obj
    /// </summary>
    public class XmlSerializerFactory
    {
        private static XmlSerializerFactory _instance = new XmlSerializerFactory();

        /// <summary>
        /// Returns instance of <code>XmlDeserializerFactory</code>.
        /// </summary>
        /// <returns></returns>
        public static XmlSerializerFactory GetInstance()
        {
            return _instance;
        }

        /// <summary>
        /// Creates speciefic Deserializer acc. to BlockType
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public IXmlSerializer Create(BlockType type)
        {
            switch (type)
            {
                case BlockType.Generator:
                    return new GeneratorXmlSerializer();
                case BlockType.ServiceChannel:
                    return new ServiceChannelXmlSerializer();
                case BlockType.Splitter:
                    return new SplitterXmlSerializer();
                case BlockType.Summator:
                    return new SummatorXmlSerializer();
                default:
                    throw new ArgumentException();
            }
        }
    }
}
